import React from 'react'
import ReactEChart from 'echarts-for-react';

// 平均年龄树状图
export default function AgeColumn({ StyleData, data, title }) {
    const options = {
        title: { text: title },
        xAxis: { max: Math.ceil(Math.max(...data.map((item) => item.age))) },
        yAxis: {
            type: 'category',
            data: data.map((item) => item.name),
            inverse: true,
            max: 1,
        },
        series: [
            {
                realtimeSort: true,
                type: 'bar',
                data: data.map((item) => item.age),
                label: {
                    show: true,
                    position: 'top',
                },
            },
        ],
    };
    return (
        <div className='staff-amount-container' style={StyleData}>
            <ReactEChart className="react_for_echarts" option={options}></ReactEChart>
        </div>
    )
}
